<!--3)	礼品领取日、月报表-->
<template>
  <div class="app-container">
    <!--    {{ searchObj }}-->
    <!-- banner列表 -->
    <div>
      <el-form :inline="true" :model="page" class="demo-form-inline">
        <el-form-item label="营销活动种类">
          <el-input v-model.trim="page.saleplanname" placeholder="刮刮卡"></el-input>
        </el-form-item>
        <el-form-item label="业务类型">
          <el-input v-model.trim="page.svcid" placeholder="0"></el-input>
        </el-form-item>
        <el-form-item label="奖品种类">
          <el-input v-model.trim="page.gifttype" placeholder="1"></el-input>
        </el-form-item>
        <el-form-item label="用户手机号">
          <el-input v-model.trim="page.pnumber" placeholder="请输入"></el-input>
        </el-form-item><br/>
        <el-form-item label="年">
          <el-input v-model.trim="page.y" placeholder="2020"></el-input>
        </el-form-item>
        <el-form-item label="月">
          <el-input v-model.trim="page.m" placeholder="01"></el-input>
        </el-form-item>
        <el-form-item label="日">
          <el-input v-model.trim="page.d" placeholder="01"></el-input>
        </el-form-item><br/>
        <el-form-item>
          <el-button type="primary" @click="onSubmit">查询</el-button>
        </el-form-item>
        <el-form-item>
          <el-button @click="GiftDayExcelDownloads()" type="primary">导出当页数据</el-button>
        </el-form-item>
      </el-form>
    </div>
    <template>
      <el-table :data="searchObj" style="width: 100%"><!--v-loading="loading"-->
        <el-table-column prop="tabSaleplanpara.saleplanname" label="营销活动种类" width="180"></el-table-column>
        <el-table-column prop="tabSaleplanpara.svcid" label="业务类型" width="180"></el-table-column>
        <el-table-column prop="tabSaleplanGiftcode.gifttype" label="奖品种类" width="180"></el-table-column>
        <el-table-column prop="tabHallUsermessage.pnumber" label="用户手机号"></el-table-column>
        <el-table-column prop="optrdate" label="领取日期"></el-table-column>
<!--        <el-table-column fixed="right" label="操作" width="200">-->
<!--          <template slot-scope="scope">-->
<!--            <el-button @click="GiftDayExcelDownloads()" type="primary" icon="el-icon-edit" size="small">导出当页数据-->
<!--            </el-button>-->
<!--            &lt;!&ndash;            <el-button @click="handleClick(scope.row)" type="primary" icon="el-icon-edit" size="small">编辑</el-button>&ndash;&gt;-->
<!--            &lt;!&ndash;            <el-button type="danger" icon="el-icon-delete" size="small">删除</el-button>&ndash;&gt;-->
<!--          </template>-->
<!--        </el-table-column>-->
        <!-- 分页 -->
      </el-table>
    </template>
    <el-pagination
        :current-page="pageNo"
        :page-size="pageSize"
        :total="total"
        style="padding: 30px 0; text-align: center;"
        layout="total, prev, pager, next, jumper"
        @current-change="getList"
    />
  </div>
</template>
<script>
//引入api接口
import giftDay from "../../api/giftDay";

export default {
  // 定义数据模型
  data() {
    return {
      pageNo: 1,
      pageSize: 2,
      searchObj: [{
        optrdate: null,
        tabHallUsermessage: [{
          pnumber: null
        }],
        tabSaleplanGiftcode: [{
          gifttype: null
        }],
        tabSaleplanpara: [{
          saleplanname: null,
          svcid: null
        }]
      }],
      //方法传的参数对象
      page: {
        pageNo: 1,
        pageSize: 2,
        saleplanname: null,
        svcid: null,
        gifttype:null,
        pnumber: null,
        y: null,
        m: null,
        d: null
      },
      total: 0
    }
  },
  // 页面渲染成功后获取数据
  created() {
    this.getList();
  },

  methods: {//定义方法对api接口的方法调用
    //医院设置列表
    getList(page = 1) {
      this.page.pageNo = page
      giftDay.selectGiftDay(this.page)
          .then(res => {
            this.total = res.data.total
            this.searchObj = res.data.list
            console.log(res)
          })//请求成功
          .catch(error => {
            console.log(error)
          })//请求失败
    }, onSubmit() {
      this.getList();
    },
    GiftDayExcelDownloads() {
      // alert(this.page.pageNo)
      // alert(this.page.saleplanname+"/n"+this.page.svcid+"/n"+this.page.gifttype+"/n"+this.page.pnumber+"/n"+this.page.y+"/n"+this.page.m+"/n"+this.page.d)
      var msg = "确定要导出数据吗？";
      if (confirm(msg) == true) {
        window.location.href = "http://localhost:9527/userTest/tab-saleplan-giftlog/scratch/GiftReceivingDayExcelDownloads?" +
            "pageNo=" + this.page.pageNo+
            "&saleplanname="+this.page.saleplanname+
            "&svcid="+this.page.svcid+
            "&gifttype="+this.page.gifttype+
            "&pnumber="+this.page.pnumber+
            "&y="+this.page.y+
            "&m="+this.page.m+
            "&d="+this.page.d;
      }
    }
  }
};
</script>
